<template>
  <div class="home">
    <div class="Swipe" style="width: 375px;overflow: hidden;">
      <!-- <van-swipe :autoplay="3000" indicator-color="white" class="swipe">
        <van-swipe-item v-for=" item in lunbotuList" :key="item.img" class="item">
          <img :src="item.img" alt>
        </van-swipe-item>
      </van-swipe> -->
      <swipe :lunbotuList="lunbotuList"></swipe>
    </div>
    <gird></gird>
  </div>
</template>
<script>
import gird from '../../components/gird';
import swipe from '../../components/swipe'
export default {
  data() {
    return {
      lunbotuList: [],
    };
  },
  created() {
    this.getLunbotu();
  },
  components:{
    gird,
    swipe
  },
  methods: {
 /*    getLunbotu() {
      //获取轮播图的数据
      this.$http.get("http://localhost:5000/api/getlunbo").then(res => {
        console.log(res);

        if (res.body.status === 0) {
          this.lunbotuList = res.body.message;
        } else {
          console.log("请求失败");
        }
      }); */
/*     getLunbotu() {
      //获取轮播图的数据
      this.$http.get("api/getlunbo").then(res => {
        console.log(res);
        const {data:{message,status}}= res; //解构赋值
        if (status == 0) {
          this.lunbotuList = message;
        } else {
          console.log("请求失败");
        }
      });
    } */
    async getLunbotu() {
      const {
        data:{message,status}
      }= await  this.$http.get("api/getlunbo"); 
      if (status == 0) {
        this.lunbotuList = message;
      } else {
        console.log("请求失败");
      }
    }
  }
};
</script>
<style lang="less">
</style>